package twu;

/**
 * Created by twer on 7/9/14.
 */
public class DrawRobot {
    public String drawOneAsterisk() {
        return "*";
    }

    public String drawHorizontalLine(int size) {
        String drawString = "";
        for (int i = 0; i < size; i++){
            drawString += "*";
        }
        return drawString;
    }

    public String drawVerticalLine(int size) {
        String drawString = "";
        for (int i = 0; i < size; i++) {
            drawString += "*\n";
        }
        return drawString;
    }

    public String drawRightTriangle(int size) {
        String drawString = "";
        for (int i = 0; i < size; i++){
            for ( int j = 0; j < i + 1 ; j++){
                drawString += "*";
            }
            drawString += "\n";
        }
        return drawString;
    }

    public String drawIsoscelesTriangle(int size) {
        String drawString = "";
        for (int i = 0; i < size; i++){
            for ( int j = 0; j < size - i - 1 ; j++){
                drawString += " ";
            }
            for ( int k = 0; k < 2 * i + 1 ; k++){
                drawString += "*";
            }
            drawString += "\n";
        }
        return drawString;
    }

    public String drawDiamond(int size) {
        String drawString = drawIsoscelesTriangle(size);
        drawString += drawLeftTriangle(size);
        return drawString;
    }

    private String drawLeftTriangle(int size) {
        String leftString = "";
        for (int i = size - 1 ; i > 0 ; i--){
            for ( int j = 0; j < size - i ; j++){
                leftString += " ";
            }
            for ( int k = 0; k < 2 * i - 1 ; k++){
                leftString += "*";
            }
            leftString += "\n";
        }
        return leftString;
    }

    public String drawDiamondWithName(int size) {
        String drawString = "" ;
        for (int i = 0; i < size - 1; i++){
            for ( int j = 0; j < size - i - 1 ; j++){
                drawString += " ";
            }
            for ( int k = 0; k < 2 * i + 1 ; k++){
                drawString += "*";
            }
            drawString += "\n";
        }
        drawString += "txli\n";
        drawString += drawLeftTriangle(size);
        return drawString;
    }
}
